/*****************************************************************************
 *   adc.h:  Header file for NXP LPC23xx Family Microprocessors
 *
 *   Copyright(C) 2006, NXP Semiconductor
 *   All rights reserved.
 *
 *   History
 *   2006.09.20  ver 1.00    Prelimnary version, first Release
 *
******************************************************************************/
#ifndef __ADC_H
#define __ADC_H

#ifdef __cplusplus
extern "C" {
#endif
  #include "type.h"
#define ADC_INTERRUPT_FLAG  1 /* 1 is interrupt driven, 0 is polling */

#define ADC_OFFSET    0x10
#define ADC_INDEX   4

#define ADC_DONE    0x80000000
#define ADC_OVERRUN   0x40000000
#define ADC_ADINT   0x00010000

#define ADC_NUM     8   /* for LPC23xx */
#define ADC_CLK     1000000   /* set to 1Mhz */

#define AD0_BASE_ADDR ((unsigned int)&AD0CR)
  
  
#define AD0CR_START_BIT  24  
#define AD0CR_PDN_BIT    21   
#define AD0GDR_DONE_MASK 0x80000000
#define PCONP_PCAD_BIT   12  
  
  
  
extern __irq __nested __arm void ADC0Handler( void );


DWORD ADCInit();
DWORD ADC0Read(unsigned int channelNum );

int TEMP_Measuring(void);
int BAT_Measuring(void);


void adc_disable();
int Convert_TEMP(unsigned int value);
#ifdef __cplusplus
}
#endif
#endif /* end __ADC_H */
/*****************************************************************************
**                            End Of File
******************************************************************************/
